<?php
/* @var $this ProductController */
/* @var $model Product */

$this->breadcrumbs=array(
	'Products'=>array('index'),
	$model->id,
);

$this->menu=array(
	array('label'=>'List Product', 'url'=>array('index')),
	array('label'=>'Create Product', 'url'=>array('create')),
	array('label'=>'Update Product', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Product', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
	array('label'=>'Manage Product', 'url'=>array('admin')),
);
?>

<!--h1>View Product #<?php //echo $model->id; ?></h1-->
<div class="primary_block row block">
	<div class="product-container" style="margin-bottom: 2px; height:410px;">
		<div class="product-image">
			<!-- <div id="image-block" class="clearfix">
				<img id="bigpic" itemprop="image" src="<?php //echo Yii::app()->request->baseUrl.'/images/product/'.$model['image_link']; ?>" title="Class aptent taciti socs" alt="" title="">
			</div>
			<div id="views_block" class="clearfix ">
				<div id="thumbs_list">
					<ul id="thumbs_list_frame" style="width: 495px;">
						<li id="thumbnail_174"> -->
							<!-- <a href="http://demo4leotheme.com/prestashop/leo_gift_shop_demo/174-thickbox_default/printed-summer-dress.jpg" data-fancybox-group="other-views" class="fancybox" 	title="Class aptent taciti socs"> -->
								<!-- <img class="img-responsive" id="thumb_174" src="http://demo4leotheme.com/prestashop/leo_gift_shop_demo/174-cart_default/printed-summer-dress.jpg" alt="Class aptent taciti socs" title="Class aptent taciti socs" itemprop="image"> -->
							<!-- </a> -->
						<!-- </li>
					</ul>
				</div>
			</div> -->

			<div id="product-gallery">
			    <div id="gallery">
				<?php
					$gallery = '<div id="slides">';
					$gallery_menu = '<div id="gallery-menu"><ul>';
					if ($model->image_link && $model->image_link != '' && $model->image_link != null) {
						$gallery .= '<div class="slide"><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$model->image_link.'" width="265" height="235" alt="side" /></div>';
						$gallery_menu .= '<li class="menuItem"><a href=""><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$model->image_link.'" width="48" height="48" alt="thumbnail" /></a></li>';
					}
					if ($productimage->image_1 && $productimage->image_1 != '' && $productimage->image_1 != null) {
						$gallery .= '<div class="slide"><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_1.'" width="265" height="235" alt="side" /></div>';
						$gallery_menu .= '<li class="menuItem"><a href=""><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_1.'" width="48" height="48" alt="thumbnail" /></a></li>';
					}
					if ($productimage->image_2 && $productimage->image_2 != '' && $productimage->image_2 != null) {
						$gallery .= '<div class="slide"><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_2.'" width="265" height="235" alt="side" /></div>';
						$gallery_menu .= '<li class="menuItem"><a href=""><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_2.'" width="48" height="48" alt="thumbnail" /></a></li>';
					}
					if ($productimage->image_3 && $productimage->image_3 != '' && $productimage->image_3 != null) {
						$gallery .= '<div class="slide"><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_3.'" width="265" height="235" alt="side" /></div>';
						$gallery_menu .= '<li class="menuItem"><a href=""><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_3.'" width="48" height="48" alt="thumbnail" /></a></li>';
					}
					if ($productimage->image_4 && $productimage->image_4 != '' && $productimage->image_4 != null) {
						$gallery .= '<div class="slide"><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_4.'" width="265" height="235" alt="side" /></div>';
						$gallery_menu .= '<li class="menuItem"><a href=""><img src="'.Yii::app()->request->baseUrl.'/images/Product/'.$productimage->image_4.'" width="48" height="48" alt="thumbnail" /></a></li>';
					}
					$gallery .= '</div>';
					$gallery_menu .= '</ul></div>';
					echo $gallery;
					echo $gallery_menu;
				?>
			        
			  </div>
			</div>
			<script type="text/javascript">
				var totWidth=0;
				var positions = new Array();
				$('#slides .slide').each(function(i){
					positions[i]= totWidth;
					totWidth += $(this).width();
					
					if(!$(this).width()) {
						alert("Please, fill in width & height for all your images!");
						return false;
					}
					
				});
				
				$('#slides').width(totWidth);
				$('#gallery-menu ul li a').click(function(e,keepScroll){
						$('li.menuItem').removeClass('act').addClass('inact');
						$(this).parent().addClass('act');
						
						var pos = $(this).parent().prevAll('.menuItem').length;
						
						$('#slides').stop().animate({marginLeft:-positions[pos]+'px'},300);
						e.preventDefault();
						if(!keepScroll) clearInterval(itvl);
				});
				
				$('#gallery-menu ul li.menuItem:first').addClass('act').siblings().addClass('inact');

				var current=1;
				function autoAdvance() {
					if(current==-1) return false;
					
					$('#gallery-menu ul li a').eq(current%$('#gallery-menu ul li a').length).trigger('click',[true]);	// [true] will be passed as the keepScroll parameter of the click function on line 28
					current++;
				}
				var changeEvery = 10;
				var itvl = setInterval(function(){autoAdvance()},changeEvery*500);
			</script>
		</div>
		<div class="pb-right-column col-xs-12 col-sm-6 col-md-7 col-lg-7">		
			<h2 itemprop="name"><?php echo $model->product_name; ?></h2>	
			<p class="product_reference">
				<label>Danh mục: </label>
				<span class="editable" itemprop="sku">
					<?php echo CHtml::link($category_name,array('category/view','id'=>$model->category_id)); ?>
				</span>
			</p>
			<p class="product_condition">Mô tả sản phẩm:</p>
			<div id="short_description_block">
				<div id="short_description_content" class="rte align_justify" itemprop="description">
					<p><?php echo "'".$model->description."'"; ?></p>
				</div>	
			</div> <!-- end short_description_block -->
			<div class="box-info-product">
				<div class="content_prices clearfix">
					<div class="price">
						<label class="gia-san-pham">Giá: </label>
						<p class="our_price_display">
							<span><?php echo number_format($model->cost).' VNĐ'; ?></span>
						</p>
						<?php
						if($model->cost_sale != 0 && $model->cost_sale != NULL) { ?>
							<script type="text/javascript">
								$(".our_price_display").addClass("product_old_price");
							</script>
							<p id="sale_price">
								<span id="sale_price_display"><?php echo number_format($model->cost_sale).' VNĐ'; ?></span>
							</p>
							<p id="reduction_percent">
								<span id="reduction_percent_display"><strong><?php echo '–'.ceil(100 - ($model->cost_sale * 100/$model->cost))."%"; ?></strong></span>
							</p>
						<?php } ?>
					</div> <!-- end prices -->
					<p id="reduction_amount" style="display: none;">
						<span id="reduction_amount_display"></span>
					</p>
					<div class="clear"></div>
				</div> <!-- end content_prices -->			
		</div> <!-- end box-info-product -->
			<div class="social-share">
				<div class="linkedin-twitter">
					<?php
						$this->widget('application.extensions.SocialShareButton.SocialShareButton', array(
					        'style'=>'horizontal',
					        'networks' => array('linkedin','twitter'),
					        'data_via'=>'hungnup', //twitter username (for twitter only, if exists else leave empty)
						));
					?>
				</div>
				<div class="facebook">
					<div id="fb-root"></div>
					<script>(function(d, s, id) {
					  var js, fjs = d.getElementsByTagName(s)[0];
					  if (d.getElementById(id)) return;
					  js = d.createElement(s); js.id = id;
					  js.src = "//connect.facebook.net/vi_VN/sdk.js#xfbml=1&version=v2.0";
					  fjs.parentNode.insertBefore(js, fjs);
					}(document, 'script', 'facebook-jssdk'));</script>
					<div class="fb-like" data-href="https://www.facebook.com/rembachduong" data-layout="button_count" data-action="like" data-show-faces="false" data-share="true"></div>
				</div>
				<div class="google-plus">
					<!-- Đặt thẻ này vào phần đầu hoặc ngay trước thẻ đóng phần nội dung của bạn. -->
					<script src="https://apis.google.com/js/platform.js" async defer>
					  {lang: 'vi'}
					</script>
					<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="300" data-href="http://rembachduong.vn"></div>
				</div>
			</div>
		</div> <!-- end pb-right-column-->
	</div>
	<script type="text/javascript">
		function related_infr() {
			$("#product-related-comment").removeClass("active");
			$("#product-related-support").removeClass("active");
			$("#product-related-info").addClass("active");
			$(".product_tabs_container .product-comment").removeClass("active");
			$(".product_tabs_container .product-support").removeClass("active");
			$(".product_tabs_container .product-info").eq($(this).index()).addClass("active");
		}

		function related_comment() {
			$("#product-related-info").removeClass("active");
			$("#product-related-support").removeClass("support");
			$("#product-related-comment").addClass("active");
			$(".product_tabs_container .product-info").removeClass("active");
			$(".product_tabs_container .product-support").removeClass("active");
			$(".product_tabs_container .product-comment").eq($(this).index()).addClass("active");
		}

		function related_support() {
			$("#product-related-info").removeClass("active");
			$("#product-related-comment").removeClass("active");
			$("#product-related-support").addClass("active");
			$(".product_tabs_container .product-info").removeClass("active");
			$(".product_tabs_container .product-comment").removeClass("active");
			$(".product_tabs_container .product-support").eq($(this).index()).addClass("active");
		}
	</script>
	<div class="product_related">
	    <!-- product related left column -->
	    <div class="product_related_left">
	        <ul class="product_tabs_trigger clearfix">
	            <li id="product-related-info" onclick="related_infr()" class="active">Thông tin</li>
	            <li id="product-related-comment" onclick="related_comment()" >Bình luận</li>
	            <li id="product-related-support" onclick="related_support()" >Hướng dẫn mua hàng</li>
	        </ul>
	        <div class="product_tabs_container">
                <div class="product-info tab_content active">
                    <span><?php echo $model->content; ?></span>
                </div>
                <div class="product-comment tab_content">
                	<p>Viết comment của bạn: </p>
                    <div id="fb-root"></div>
					<script>(function(d, s, id) {
					  var js, fjs = d.getElementsByTagName(s)[0];
					  if (d.getElementById(id)) return;
					  js = d.createElement(s); js.id = id;
					  js.src = "//connect.facebook.net/vi_VN/sdk.js#xfbml=1&version=v2.0";
					  fjs.parentNode.insertBefore(js, fjs);
					}(document, 'script', 'facebook-jssdk'));</script>
					<div class="fb-comments" data-href="http://localhost/thanhshop/index.php"<?php echo '/post/'.$model->id; ?> data-width="565" data-numposts="7" data-colorscheme="light"></div>
                </div>
                <div class="product-support tab_content">
                    <div class="guide_padding">
                    	<div style="float:left;margin-top:40px">
		                    <div style="color:#333;font-weight:bold;font-size:18px; margin-right: 15px;">Gọi điện thoại trực tiếp tới số <span style="color:#d13c2c;font-size:18px;font-weight:bold">0977.327.527</span></div>
		                    <div style="color:#333;font-weight:bold;font-size:18px;margin-right: 15px;;margin-bottom: 20px;">Hoặc <span style="color:#d13c2c;font-size:18px;font-weight:bold">09.8686.9922</span> để đặt hàng</div>
		                </div>
                    	<div class="list upper">Đối với vận chuyển nội thành Hà Nội</div>
	                    <div style="margin-bottom:8px"><b>Phí vận chuyển</b>: 25K - 40K</div>
	                    <div style="margin-bottom:8px"><b>Thời gian chuyển</b>: Trong vòng 12 tiếng.</div>
	                    <div style="margin-bottom:8px">Đặt hàng sáng <b>(9h-11h30)</b>, chiều nhận <b>(13h30-18h)</b>.</div>
	                    <div style="margin-bottom:8px">Đặt hàng chiều <b>(11h30-16h30)</b>, sáng hôm sau nhận <b>(9h-12h)</b>.</div>
	                    <div style="margin-bottom:8px"><i>Nếu quý khách muốn nhận hàng sớm hơn, vui lòng gọi để biết mức cước thỏa thuận.</i></div>
	                    <div style="margin-bottom:8px"><b>Thanh toán</b>: Thanh tóan trực tiếp.</div>
	                    <div class="list upper">Đối với vận chuyển toàn quốc</div>
	                    <div style="margin-bottom:8px"><b>Phí vận chuyển</b>: 30k-100k <i>(Vui lòng gọi để biết cụ thể)</i></div>
	                    <div style="margin-bottom:8px"><b>Thời gian chuyển</b>:</div>
	                    <div style="margin-bottom:8px">- Đối với các tỉnh, thành phố lớn: TP.Hồ Chí Minh, Đà Nẵng, Nha Trang, Huế, Hải Phòng…: 12h-48h</div>
	                    <div style="margin-bottom:60px">- Đối với các tỉnh, thành phố thuộc tỉnh, thị xã: 2-5 ngày.</div>
	                </div>
                </div>
	        </div>
	        </div>
	        <!-- /product related left column -->
	        <!-- product related right column -->
	        <div class="product_related_right">
	            <!-- san pham lien quan -->
	            <div class="other_products">
	                <div class="header">Sản phẩm liên quan</div>
	                <ul class="list">
	                	<?php foreach ($related_products as $key => $related_product) { ?>
                			<li>
	                    		
	                    		<img class="product_avatar" src="<?php echo Yii::app()->request->baseUrl.'/images/product/'.$related_product['image_link']; ?>" alt="<?php echo $related_product['product_name'];?>" >

		                        <a href="<?php echo Yii::app()->request->baseUrl.'/index.php/product/'.$related_product['id']; ?>" class="clearfix">
		                            <span class="product_title"><?php echo $related_product['product_name']; ?></span>
		                        </a>
	                            <span class="related_product_price"><span class="red">Giá: <?php echo number_format($related_product['cost']).' vnđ'; ?></span></span>
									<?php
									if($related_product['cost_sale'] != 0 && $related_product['cost_sale'] != NULL) { ?>
										<script type="text/javascript">
											$(".related_product_price").addClass("product_old_price");
										</script>
										<p id="related_sale_price">
											<span class="related_sale_price">Sale: <?php echo number_format($related_product['cost_sale']).' VNĐ'; ?></span>
										</p>
									<?php } ?>
								<div class="clear"></div>
		                    </li>
	                	<?php } ?>
	                </ul>
	            </div>
	            <!-- /san pham lien quan -->
	        </div>
	        <!-- /product related right column -->
	        <div class="clear"></div>
	    </div>
	</div>
		
</div>

<?php
// $this->widget('zii.widgets.CDetailView', array(
// 	'data'=>$model,
// 	'attributes'=>array(
// 		'id',
// 		'product_name',
// 		'cost',
// 		'cost_sale',
// 		'image_link',
// 		'category_id',
// 		'product_sale',
// 		'product_new',
// 		'content',
// 		'description',
// 		'created',
// 		'modified',
// 	),
// ));
?>
